package com.kunzai.threadrun;

public class RailwayticketTwO implements Runnable{
    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    private int train = 100;
    @Override
    public void run() {
        while (true){
            if (train>0){
                System.out.println(Thread.currentThread().getName()+"售卖第"+train--+"张票");
            }
            if (train==0){
                return;
            }
        }
    }
}
